{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import os\n",
    "import zipfile\n",
    "import pandas as pd\n",
    "import sqlalchemy as sql\n",
    "from sqlalchemy import create_engine\n",
    "\n",
    "from database_config import db_postgres\n",
    "\n",
    "host, port, user, password, database = db_postgres()\n",
    "\n",
    "engine = sql.create_engine(f\"postgresql+psycopg2://{user}:{password}@{host}:{port}/{database}\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "path = 'I:/Data/minzdrav'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Обрабатывается файл \"1\" : 12.01.2024.csv\n",
      "Обрабатывается файл \"2\" : 08.01.2024.csv\n",
      "Обрабатывается файл \"3\" : 17.01.2024.csv\n",
      "Обрабатывается файл \"4\" : 21.01.2024.csv\n",
      "Обрабатывается файл \"5\" : 20.01.2024.csv\n",
      "Обрабатывается файл \"6\" : 03.01.2024.csv\n",
      "Обрабатывается файл \"7\" : 09.01.2024.csv\n",
      "Обрабатывается файл \"8\" : 14.01.2024.csv\n",
      "Обрабатывается файл \"9\" : 07.01.2024.csv\n",
      "Обрабатывается файл \"10\" : 19.01.2024.csv\n",
      "Обрабатывается файл \"11\" : 05.01.2024.csv\n",
      "Обрабатывается файл \"12\" : 06.01.2024.csv\n",
      "Обрабатывается файл \"13\" : 15.01.2024.csv\n",
      "Обрабатывается файл \"14\" : 04.01.2024.csv\n",
      "Обрабатывается файл \"15\" : 16.01.2024.csv\n",
      "Обрабатывается файл \"16\" : 02.01.2024.csv\n",
      "Обрабатывается файл \"17\" : 01.01.2024.csv\n",
      "Обрабатывается файл \"18\" : 10.01.2024.csv\n",
      "Обрабатывается файл \"19\" : 13.01.2024.csv\n",
      "Обрабатывается файл \"20\" : 11.01.2024.csv\n",
      "Обрабатывается файл \"21\" : 18.01.2024.csv\n",
      "Обрабатывается файл \"22\" : 22.01.2024.csv\n",
      "Обрабатывается файл \"23\" : 23.01.2024.csv\n",
      "Обрабатывается файл \"24\" : 24.01.2024.csv\n",
      "Обрабатывается файл \"25\" : 25.01.2024.csv\n",
      "Обрабатывается файл \"26\" : 26.01.2024.csv\n",
      "Обрабатывается файл \"27\" : 27.01.2024.csv\n",
      "Обрабатывается файл \"28\" : 28.01.2024.csv\n",
      "Обрабатывается файл \"29\" : 29.01.2024.csv\n",
      "Обрабатывается файл \"30\" : 30.01.2024.csv\n",
      "Обрабатывается файл \"31\" : 31.01.2024.csv\n",
      "Обрабатывается файл \"32\" : 01.02.2024.csv\n",
      "Обрабатывается файл \"33\" : 02.02.2024.csv\n",
      "Обрабатывается файл \"34\" : 03.02.2024.csv\n",
      "Обрабатывается файл \"35\" : 04.02.2024.csv\n",
      "Обрабатывается файл \"36\" : 05.02.2024.csv\n",
      "Обрабатывается файл \"37\" : 06.02.2024.csv\n",
      "Обрабатывается файл \"38\" : 07.02.2024.csv\n",
      "Обрабатывается файл \"39\" : 08.02.2024.csv\n",
      "Обрабатывается файл \"40\" : 09.02.2024.csv\n",
      "Обрабатывается файл \"41\" : 10.02.2024.csv\n",
      "Обрабатывается файл \"42\" : 11.02.2024.csv\n",
      "Обрабатывается файл \"43\" : 12.02.2024.csv\n",
      "Обрабатывается файл \"44\" : 13.02.2024.csv\n",
      "Обрабатывается файл \"45\" : 14.02.2024.csv\n",
      "Обрабатывается файл \"46\" : 15.02.2024.csv\n",
      "Обрабатывается файл \"47\" : 16.02.2024.csv\n",
      "Обрабатывается файл \"48\" : 18.02.2024.csv\n",
      "Обрабатывается файл \"49\" : 17.02.2024.csv\n",
      "Обрабатывается файл \"50\" : 19.02.2024.csv\n",
      "Обрабатывается файл \"51\" : 20.02.2024.csv\n",
      "Обрабатывается файл \"52\" : 21.02.2024.csv\n",
      "Обрабатывается файл \"53\" : 22.02.2024.csv\n",
      "Обрабатывается файл \"54\" : 23.02.2024.csv\n",
      "Обрабатывается файл \"55\" : 25.02.2024.csv\n",
      "Ошибка при чтении файла \"24.02.2024.csv\" : ['utf-8' codec can't decode byte 0xcd in position 14: invalid continuation byte]\n",
      "Обрабатывается файл \"56\" : 24.02.2024.csv\n",
      "Обрабатывается файл \"57\" : 26.02.2024.csv\n",
      "Обрабатывается файл \"58\" : 27.02.2024.csv\n",
      "Обрабатывается файл \"59\" : 28.02.2024.csv\n",
      "Обрабатывается файл \"60\" : 29.02.2024.csv\n",
      "Обрабатывается файл \"61\" : 01.03.2024.csv\n",
      "Обрабатывается файл \"62\" : 03.03.2024.csv\n",
      "Обрабатывается файл \"63\" : 02.03.2024.csv\n",
      "Обрабатывается файл \"64\" : 04.03.2024.csv\n",
      "Обрабатывается файл \"65\" : 05.03.2024.csv\n",
      "Обрабатывается файл \"66\" : 06.03.2024.csv\n",
      "Обрабатывается файл \"67\" : 07.03.2024.csv\n",
      "Обрабатывается файл \"68\" : 08.03.2024.csv\n"
     ]
    },
    {
     "ename": "KeyboardInterrupt",
     "evalue": "",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mKeyboardInterrupt\u001b[0m                         Traceback (most recent call last)",
      "Cell \u001b[1;32mIn[11], line 30\u001b[0m\n\u001b[0;32m     28\u001b[0m file_data[\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mcreate_ts\u001b[39m\u001b[38;5;124m'\u001b[39m] \u001b[38;5;241m=\u001b[39m pd\u001b[38;5;241m.\u001b[39mto_datetime(file_data[\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mcreate_ts\u001b[39m\u001b[38;5;124m'\u001b[39m], \u001b[38;5;28mformat\u001b[39m\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m%\u001b[39m\u001b[38;5;124mY-\u001b[39m\u001b[38;5;124m%\u001b[39m\u001b[38;5;124mm-\u001b[39m\u001b[38;5;132;01m%d\u001b[39;00m\u001b[38;5;124mT\u001b[39m\u001b[38;5;124m%\u001b[39m\u001b[38;5;124mH:\u001b[39m\u001b[38;5;124m%\u001b[39m\u001b[38;5;124mM:\u001b[39m\u001b[38;5;124m%\u001b[39m\u001b[38;5;124mS.\u001b[39m\u001b[38;5;132;01m%f\u001b[39;00m\u001b[38;5;124m'\u001b[39m)\n\u001b[0;32m     29\u001b[0m \u001b[38;5;66;03m# запись в БД\u001b[39;00m\n\u001b[1;32m---> 30\u001b[0m \u001b[43mfile_data\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mto_sql\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43msession_errors\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mengine\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mif_exists\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43mappend\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mindex\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43;01mFalse\u001b[39;49;00m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mschema\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43mdb01\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m)\u001b[49m\n\u001b[0;32m     31\u001b[0m counter \u001b[38;5;241m+\u001b[39m\u001b[38;5;241m=\u001b[39m \u001b[38;5;241m1\u001b[39m\n",
      "File \u001b[1;32mc:\\Users\\oigla\\anaconda3\\lib\\site-packages\\pandas\\core\\generic.py:2987\u001b[0m, in \u001b[0;36mNDFrame.to_sql\u001b[1;34m(self, name, con, schema, if_exists, index, index_label, chunksize, dtype, method)\u001b[0m\n\u001b[0;32m   2830\u001b[0m \u001b[38;5;124;03m\"\"\"\u001b[39;00m\n\u001b[0;32m   2831\u001b[0m \u001b[38;5;124;03mWrite records stored in a DataFrame to a SQL database.\u001b[39;00m\n\u001b[0;32m   2832\u001b[0m \n\u001b[1;32m   (...)\u001b[0m\n\u001b[0;32m   2983\u001b[0m \u001b[38;5;124;03m[(1,), (None,), (2,)]\u001b[39;00m\n\u001b[0;32m   2984\u001b[0m \u001b[38;5;124;03m\"\"\"\u001b[39;00m  \u001b[38;5;66;03m# noqa:E501\u001b[39;00m\n\u001b[0;32m   2985\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mpandas\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mio\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m sql\n\u001b[1;32m-> 2987\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43msql\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mto_sql\u001b[49m\u001b[43m(\u001b[49m\n\u001b[0;32m   2988\u001b[0m \u001b[43m    \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m,\u001b[49m\n\u001b[0;32m   2989\u001b[0m \u001b[43m    \u001b[49m\u001b[43mname\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m   2990\u001b[0m \u001b[43m    \u001b[49m\u001b[43mcon\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m   2991\u001b[0m \u001b[43m    \u001b[49m\u001b[43mschema\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mschema\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m   2992\u001b[0m \u001b[43m    \u001b[49m\u001b[43mif_exists\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mif_exists\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m   2993\u001b[0m \u001b[43m    \u001b[49m\u001b[43mindex\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mindex\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m   2994\u001b[0m \u001b[43m    \u001b[49m\u001b[43mindex_label\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mindex_label\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m   2995\u001b[0m \u001b[43m    \u001b[49m\u001b[43mchunksize\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mchunksize\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m   2996\u001b[0m \u001b[43m    \u001b[49m\u001b[43mdtype\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mdtype\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m   2997\u001b[0m \u001b[43m    \u001b[49m\u001b[43mmethod\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mmethod\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m   2998\u001b[0m \u001b[43m\u001b[49m\u001b[43m)\u001b[49m\n",
      "File \u001b[1;32mc:\\Users\\oigla\\anaconda3\\lib\\site-packages\\pandas\\io\\sql.py:695\u001b[0m, in \u001b[0;36mto_sql\u001b[1;34m(frame, name, con, schema, if_exists, index, index_label, chunksize, dtype, method, engine, **engine_kwargs)\u001b[0m\n\u001b[0;32m    690\u001b[0m \u001b[38;5;28;01melif\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(frame, DataFrame):\n\u001b[0;32m    691\u001b[0m     \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mNotImplementedError\u001b[39;00m(\n\u001b[0;32m    692\u001b[0m         \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mframe\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m argument should be either a Series or a DataFrame\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[0;32m    693\u001b[0m     )\n\u001b[1;32m--> 695\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m pandas_sql\u001b[38;5;241m.\u001b[39mto_sql(\n\u001b[0;32m    696\u001b[0m     frame,\n\u001b[0;32m    697\u001b[0m     name,\n\u001b[0;32m    698\u001b[0m     if_exists\u001b[38;5;241m=\u001b[39mif_exists,\n\u001b[0;32m    699\u001b[0m     index\u001b[38;5;241m=\u001b[39mindex,\n\u001b[0;32m    700\u001b[0m     index_label\u001b[38;5;241m=\u001b[39mindex_label,\n\u001b[0;32m    701\u001b[0m     schema\u001b[38;5;241m=\u001b[39mschema,\n\u001b[0;32m    702\u001b[0m     chunksize\u001b[38;5;241m=\u001b[39mchunksize,\n\u001b[0;32m    703\u001b[0m     dtype\u001b[38;5;241m=\u001b[39mdtype,\n\u001b[0;32m    704\u001b[0m     method\u001b[38;5;241m=\u001b[39mmethod,\n\u001b[0;32m    705\u001b[0m     engine\u001b[38;5;241m=\u001b[39mengine,\n\u001b[0;32m    706\u001b[0m     \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mengine_kwargs,\n\u001b[0;32m    707\u001b[0m )\n",
      "File \u001b[1;32mc:\\Users\\oigla\\anaconda3\\lib\\site-packages\\pandas\\io\\sql.py:1738\u001b[0m, in \u001b[0;36mSQLDatabase.to_sql\u001b[1;34m(self, frame, name, if_exists, index, index_label, schema, chunksize, dtype, method, engine, **engine_kwargs)\u001b[0m\n\u001b[0;32m   1726\u001b[0m sql_engine \u001b[38;5;241m=\u001b[39m get_engine(engine)\n\u001b[0;32m   1728\u001b[0m table \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mprep_table(\n\u001b[0;32m   1729\u001b[0m     frame\u001b[38;5;241m=\u001b[39mframe,\n\u001b[0;32m   1730\u001b[0m     name\u001b[38;5;241m=\u001b[39mname,\n\u001b[1;32m   (...)\u001b[0m\n\u001b[0;32m   1735\u001b[0m     dtype\u001b[38;5;241m=\u001b[39mdtype,\n\u001b[0;32m   1736\u001b[0m )\n\u001b[1;32m-> 1738\u001b[0m total_inserted \u001b[38;5;241m=\u001b[39m sql_engine\u001b[38;5;241m.\u001b[39minsert_records(\n\u001b[0;32m   1739\u001b[0m     table\u001b[38;5;241m=\u001b[39mtable,\n\u001b[0;32m   1740\u001b[0m     con\u001b[38;5;241m=\u001b[39m\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mconnectable,\n\u001b[0;32m   1741\u001b[0m     frame\u001b[38;5;241m=\u001b[39mframe,\n\u001b[0;32m   1742\u001b[0m     name\u001b[38;5;241m=\u001b[39mname,\n\u001b[0;32m   1743\u001b[0m     index\u001b[38;5;241m=\u001b[39mindex,\n\u001b[0;32m   1744\u001b[0m     schema\u001b[38;5;241m=\u001b[39mschema,\n\u001b[0;32m   1745\u001b[0m     chunksize\u001b[38;5;241m=\u001b[39mchunksize,\n\u001b[0;32m   1746\u001b[0m     method\u001b[38;5;241m=\u001b[39mmethod,\n\u001b[0;32m   1747\u001b[0m     \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mengine_kwargs,\n\u001b[0;32m   1748\u001b[0m )\n\u001b[0;32m   1750\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mcheck_case_sensitive(name\u001b[38;5;241m=\u001b[39mname, schema\u001b[38;5;241m=\u001b[39mschema)\n\u001b[0;32m   1751\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m total_inserted\n",
      "File \u001b[1;32mc:\\Users\\oigla\\anaconda3\\lib\\site-packages\\pandas\\io\\sql.py:1325\u001b[0m, in \u001b[0;36mSQLAlchemyEngine.insert_records\u001b[1;34m(self, table, con, frame, name, index, schema, chunksize, method, **engine_kwargs)\u001b[0m\n\u001b[0;32m   1322\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01msqlalchemy\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m exc\n\u001b[0;32m   1324\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[1;32m-> 1325\u001b[0m     \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mtable\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43minsert\u001b[49m\u001b[43m(\u001b[49m\u001b[43mchunksize\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mchunksize\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mmethod\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mmethod\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m   1326\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m exc\u001b[38;5;241m.\u001b[39mSQLAlchemyError \u001b[38;5;28;01mas\u001b[39;00m err:\n\u001b[0;32m   1327\u001b[0m     \u001b[38;5;66;03m# GH34431\u001b[39;00m\n\u001b[0;32m   1328\u001b[0m     \u001b[38;5;66;03m# https://stackoverflow.com/a/67358288/6067848\u001b[39;00m\n\u001b[0;32m   1329\u001b[0m     msg \u001b[38;5;241m=\u001b[39m \u001b[38;5;124mr\u001b[39m\u001b[38;5;124m\"\"\"\u001b[39m\u001b[38;5;124m(\u001b[39m\u001b[38;5;124m\\\u001b[39m\u001b[38;5;124m(1054, \u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mUnknown column \u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124minf(e0)?\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m in \u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mfield list\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m\\\u001b[39m\u001b[38;5;124m))(?#\u001b[39m\n\u001b[0;32m   1330\u001b[0m \u001b[38;5;124m    )|inf can not be used with MySQL\u001b[39m\u001b[38;5;124m\"\"\"\u001b[39m\n",
      "File \u001b[1;32mc:\\Users\\oigla\\anaconda3\\lib\\site-packages\\pandas\\io\\sql.py:946\u001b[0m, in \u001b[0;36mSQLTable.insert\u001b[1;34m(self, chunksize, method)\u001b[0m\n\u001b[0;32m    943\u001b[0m     \u001b[38;5;28;01mbreak\u001b[39;00m\n\u001b[0;32m    945\u001b[0m chunk_iter \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mzip\u001b[39m(\u001b[38;5;241m*\u001b[39m(arr[start_i:end_i] \u001b[38;5;28;01mfor\u001b[39;00m arr \u001b[38;5;129;01min\u001b[39;00m data_list))\n\u001b[1;32m--> 946\u001b[0m num_inserted \u001b[38;5;241m=\u001b[39m \u001b[43mexec_insert\u001b[49m\u001b[43m(\u001b[49m\u001b[43mconn\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mkeys\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mchunk_iter\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m    947\u001b[0m \u001b[38;5;66;03m# GH 46891\u001b[39;00m\n\u001b[0;32m    948\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m is_integer(num_inserted):\n",
      "File \u001b[1;32mc:\\Users\\oigla\\anaconda3\\lib\\site-packages\\pandas\\io\\sql.py:853\u001b[0m, in \u001b[0;36mSQLTable._execute_insert\u001b[1;34m(self, conn, keys, data_iter)\u001b[0m\n\u001b[0;32m    841\u001b[0m \u001b[38;5;124;03m\"\"\"\u001b[39;00m\n\u001b[0;32m    842\u001b[0m \u001b[38;5;124;03mExecute SQL statement inserting data\u001b[39;00m\n\u001b[0;32m    843\u001b[0m \n\u001b[1;32m   (...)\u001b[0m\n\u001b[0;32m    850\u001b[0m \u001b[38;5;124;03m   Each item contains a list of values to be inserted\u001b[39;00m\n\u001b[0;32m    851\u001b[0m \u001b[38;5;124;03m\"\"\"\u001b[39;00m\n\u001b[0;32m    852\u001b[0m data \u001b[38;5;241m=\u001b[39m [\u001b[38;5;28mdict\u001b[39m(\u001b[38;5;28mzip\u001b[39m(keys, row)) \u001b[38;5;28;01mfor\u001b[39;00m row \u001b[38;5;129;01min\u001b[39;00m data_iter]\n\u001b[1;32m--> 853\u001b[0m result \u001b[38;5;241m=\u001b[39m \u001b[43mconn\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mexecute\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mtable\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43minsert\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mdata\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m    854\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m result\u001b[38;5;241m.\u001b[39mrowcount\n",
      "File \u001b[1;32mc:\\Users\\oigla\\anaconda3\\lib\\site-packages\\sqlalchemy\\engine\\base.py:1306\u001b[0m, in \u001b[0;36mConnection.execute\u001b[1;34m(self, statement, *multiparams, **params)\u001b[0m\n\u001b[0;32m   1302\u001b[0m     util\u001b[38;5;241m.\u001b[39mraise_(\n\u001b[0;32m   1303\u001b[0m         exc\u001b[38;5;241m.\u001b[39mObjectNotExecutableError(statement), replace_context\u001b[38;5;241m=\u001b[39merr\n\u001b[0;32m   1304\u001b[0m     )\n\u001b[0;32m   1305\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[1;32m-> 1306\u001b[0m     \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mmeth\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mmultiparams\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mparams\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43m_EMPTY_EXECUTION_OPTS\u001b[49m\u001b[43m)\u001b[49m\n",
      "File \u001b[1;32mc:\\Users\\oigla\\anaconda3\\lib\\site-packages\\sqlalchemy\\sql\\elements.py:332\u001b[0m, in \u001b[0;36mClauseElement._execute_on_connection\u001b[1;34m(self, connection, multiparams, params, execution_options, _force)\u001b[0m\n\u001b[0;32m    328\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21m_execute_on_connection\u001b[39m(\n\u001b[0;32m    329\u001b[0m     \u001b[38;5;28mself\u001b[39m, connection, multiparams, params, execution_options, _force\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mFalse\u001b[39;00m\n\u001b[0;32m    330\u001b[0m ):\n\u001b[0;32m    331\u001b[0m     \u001b[38;5;28;01mif\u001b[39;00m _force \u001b[38;5;129;01mor\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39msupports_execution:\n\u001b[1;32m--> 332\u001b[0m         \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mconnection\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_execute_clauseelement\u001b[49m\u001b[43m(\u001b[49m\n\u001b[0;32m    333\u001b[0m \u001b[43m            \u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mmultiparams\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mparams\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mexecution_options\u001b[49m\n\u001b[0;32m    334\u001b[0m \u001b[43m        \u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m    335\u001b[0m     \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[0;32m    336\u001b[0m         \u001b[38;5;28;01mraise\u001b[39;00m exc\u001b[38;5;241m.\u001b[39mObjectNotExecutableError(\u001b[38;5;28mself\u001b[39m)\n",
      "File \u001b[1;32mc:\\Users\\oigla\\anaconda3\\lib\\site-packages\\sqlalchemy\\engine\\base.py:1498\u001b[0m, in \u001b[0;36mConnection._execute_clauseelement\u001b[1;34m(self, elem, multiparams, params, execution_options)\u001b[0m\n\u001b[0;32m   1486\u001b[0m compiled_cache \u001b[38;5;241m=\u001b[39m execution_options\u001b[38;5;241m.\u001b[39mget(\n\u001b[0;32m   1487\u001b[0m     \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mcompiled_cache\u001b[39m\u001b[38;5;124m\"\u001b[39m, \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mengine\u001b[38;5;241m.\u001b[39m_compiled_cache\n\u001b[0;32m   1488\u001b[0m )\n\u001b[0;32m   1490\u001b[0m compiled_sql, extracted_params, cache_hit \u001b[38;5;241m=\u001b[39m elem\u001b[38;5;241m.\u001b[39m_compile_w_cache(\n\u001b[0;32m   1491\u001b[0m     dialect\u001b[38;5;241m=\u001b[39mdialect,\n\u001b[0;32m   1492\u001b[0m     compiled_cache\u001b[38;5;241m=\u001b[39mcompiled_cache,\n\u001b[1;32m   (...)\u001b[0m\n\u001b[0;32m   1496\u001b[0m     linting\u001b[38;5;241m=\u001b[39m\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mdialect\u001b[38;5;241m.\u001b[39mcompiler_linting \u001b[38;5;241m|\u001b[39m compiler\u001b[38;5;241m.\u001b[39mWARN_LINTING,\n\u001b[0;32m   1497\u001b[0m )\n\u001b[1;32m-> 1498\u001b[0m ret \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_execute_context\u001b[49m\u001b[43m(\u001b[49m\n\u001b[0;32m   1499\u001b[0m \u001b[43m    \u001b[49m\u001b[43mdialect\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m   1500\u001b[0m \u001b[43m    \u001b[49m\u001b[43mdialect\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mexecution_ctx_cls\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_init_compiled\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m   1501\u001b[0m \u001b[43m    \u001b[49m\u001b[43mcompiled_sql\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m   1502\u001b[0m \u001b[43m    \u001b[49m\u001b[43mdistilled_params\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m   1503\u001b[0m \u001b[43m    \u001b[49m\u001b[43mexecution_options\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m   1504\u001b[0m \u001b[43m    \u001b[49m\u001b[43mcompiled_sql\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m   1505\u001b[0m \u001b[43m    \u001b[49m\u001b[43mdistilled_params\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m   1506\u001b[0m \u001b[43m    \u001b[49m\u001b[43melem\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m   1507\u001b[0m \u001b[43m    \u001b[49m\u001b[43mextracted_params\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m   1508\u001b[0m \u001b[43m    \u001b[49m\u001b[43mcache_hit\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mcache_hit\u001b[49m\u001b[43m,\u001b[49m\n\u001b[0;32m   1509\u001b[0m \u001b[43m\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m   1510\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m has_events:\n\u001b[0;32m   1511\u001b[0m     \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mdispatch\u001b[38;5;241m.\u001b[39mafter_execute(\n\u001b[0;32m   1512\u001b[0m         \u001b[38;5;28mself\u001b[39m,\n\u001b[0;32m   1513\u001b[0m         elem,\n\u001b[1;32m   (...)\u001b[0m\n\u001b[0;32m   1517\u001b[0m         ret,\n\u001b[0;32m   1518\u001b[0m     )\n",
      "File \u001b[1;32mc:\\Users\\oigla\\anaconda3\\lib\\site-packages\\sqlalchemy\\engine\\base.py:1862\u001b[0m, in \u001b[0;36mConnection._execute_context\u001b[1;34m(self, dialect, constructor, statement, parameters, execution_options, *args, **kw)\u001b[0m\n\u001b[0;32m   1859\u001b[0m             branched\u001b[38;5;241m.\u001b[39mclose()\n\u001b[0;32m   1861\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mBaseException\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m e:\n\u001b[1;32m-> 1862\u001b[0m     \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_handle_dbapi_exception\u001b[49m\u001b[43m(\u001b[49m\n\u001b[0;32m   1863\u001b[0m \u001b[43m        \u001b[49m\u001b[43me\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mstatement\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mparameters\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mcursor\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mcontext\u001b[49m\n\u001b[0;32m   1864\u001b[0m \u001b[43m    \u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m   1866\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m result\n",
      "File \u001b[1;32mc:\\Users\\oigla\\anaconda3\\lib\\site-packages\\sqlalchemy\\engine\\base.py:2047\u001b[0m, in \u001b[0;36mConnection._handle_dbapi_exception\u001b[1;34m(self, e, statement, parameters, cursor, context)\u001b[0m\n\u001b[0;32m   2043\u001b[0m         util\u001b[38;5;241m.\u001b[39mraise_(\n\u001b[0;32m   2044\u001b[0m             sqlalchemy_exception, with_traceback\u001b[38;5;241m=\u001b[39mexc_info[\u001b[38;5;241m2\u001b[39m], from_\u001b[38;5;241m=\u001b[39me\n\u001b[0;32m   2045\u001b[0m         )\n\u001b[0;32m   2046\u001b[0m     \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[1;32m-> 2047\u001b[0m         \u001b[43mutil\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mraise_\u001b[49m\u001b[43m(\u001b[49m\u001b[43mexc_info\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;241;43m1\u001b[39;49m\u001b[43m]\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mwith_traceback\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mexc_info\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;241;43m2\u001b[39;49m\u001b[43m]\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m   2049\u001b[0m \u001b[38;5;28;01mfinally\u001b[39;00m:\n\u001b[0;32m   2050\u001b[0m     \u001b[38;5;28;01mdel\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_reentrant_error\n",
      "File \u001b[1;32mc:\\Users\\oigla\\anaconda3\\lib\\site-packages\\sqlalchemy\\util\\compat.py:208\u001b[0m, in \u001b[0;36mraise_\u001b[1;34m(***failed resolving arguments***)\u001b[0m\n\u001b[0;32m    205\u001b[0m     exception\u001b[38;5;241m.\u001b[39m__cause__ \u001b[38;5;241m=\u001b[39m replace_context\n\u001b[0;32m    207\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[1;32m--> 208\u001b[0m     \u001b[38;5;28;01mraise\u001b[39;00m exception\n\u001b[0;32m    209\u001b[0m \u001b[38;5;28;01mfinally\u001b[39;00m:\n\u001b[0;32m    210\u001b[0m     \u001b[38;5;66;03m# credit to\u001b[39;00m\n\u001b[0;32m    211\u001b[0m     \u001b[38;5;66;03m# https://cosmicpercolator.com/2016/01/13/exception-leaks-in-python-2-and-3/\u001b[39;00m\n\u001b[0;32m    212\u001b[0m     \u001b[38;5;66;03m# as the __traceback__ object creates a cycle\u001b[39;00m\n\u001b[0;32m    213\u001b[0m     \u001b[38;5;28;01mdel\u001b[39;00m exception, replace_context, from_, with_traceback\n",
      "File \u001b[1;32mc:\\Users\\oigla\\anaconda3\\lib\\site-packages\\sqlalchemy\\engine\\base.py:1799\u001b[0m, in \u001b[0;36mConnection._execute_context\u001b[1;34m(self, dialect, constructor, statement, parameters, execution_options, *args, **kw)\u001b[0m\n\u001b[0;32m   1797\u001b[0m                 \u001b[38;5;28;01mbreak\u001b[39;00m\n\u001b[0;32m   1798\u001b[0m     \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m evt_handled:\n\u001b[1;32m-> 1799\u001b[0m         \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mdialect\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mdo_executemany\u001b[49m\u001b[43m(\u001b[49m\n\u001b[0;32m   1800\u001b[0m \u001b[43m            \u001b[49m\u001b[43mcursor\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mstatement\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mparameters\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mcontext\u001b[49m\n\u001b[0;32m   1801\u001b[0m \u001b[43m        \u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m   1802\u001b[0m \u001b[38;5;28;01melif\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m parameters \u001b[38;5;129;01mand\u001b[39;00m context\u001b[38;5;241m.\u001b[39mno_parameters:\n\u001b[0;32m   1803\u001b[0m     \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mdialect\u001b[38;5;241m.\u001b[39m_has_events:\n",
      "File \u001b[1;32mc:\\Users\\oigla\\anaconda3\\lib\\site-packages\\sqlalchemy\\dialects\\postgresql\\psycopg2.py:953\u001b[0m, in \u001b[0;36mPGDialect_psycopg2.do_executemany\u001b[1;34m(self, cursor, statement, parameters, context)\u001b[0m\n\u001b[0;32m    951\u001b[0m         kwargs \u001b[38;5;241m=\u001b[39m {}\n\u001b[0;32m    952\u001b[0m     xtras \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_psycopg2_extras()\n\u001b[1;32m--> 953\u001b[0m     context\u001b[38;5;241m.\u001b[39m_psycopg2_fetched_rows \u001b[38;5;241m=\u001b[39m xtras\u001b[38;5;241m.\u001b[39mexecute_values(\n\u001b[0;32m    954\u001b[0m         cursor,\n\u001b[0;32m    955\u001b[0m         statement,\n\u001b[0;32m    956\u001b[0m         parameters,\n\u001b[0;32m    957\u001b[0m         template\u001b[38;5;241m=\u001b[39mexecutemany_values,\n\u001b[0;32m    958\u001b[0m         fetch\u001b[38;5;241m=\u001b[39m\u001b[38;5;28mbool\u001b[39m(context\u001b[38;5;241m.\u001b[39mcompiled\u001b[38;5;241m.\u001b[39mreturning),\n\u001b[0;32m    959\u001b[0m         \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs\n\u001b[0;32m    960\u001b[0m     )\n\u001b[0;32m    962\u001b[0m \u001b[38;5;28;01melif\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mexecutemany_mode \u001b[38;5;241m&\u001b[39m EXECUTEMANY_BATCH:\n\u001b[0;32m    963\u001b[0m     \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mexecutemany_batch_page_size:\n",
      "File \u001b[1;32mc:\\Users\\oigla\\anaconda3\\lib\\site-packages\\psycopg2\\extras.py:1299\u001b[0m, in \u001b[0;36mexecute_values\u001b[1;34m(cur, sql, argslist, template, page_size, fetch)\u001b[0m\n\u001b[0;32m   1297\u001b[0m     parts\u001b[38;5;241m.\u001b[39mappend(\u001b[38;5;124mb\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m,\u001b[39m\u001b[38;5;124m'\u001b[39m)\n\u001b[0;32m   1298\u001b[0m parts[\u001b[38;5;241m-\u001b[39m\u001b[38;5;241m1\u001b[39m:] \u001b[38;5;241m=\u001b[39m post\n\u001b[1;32m-> 1299\u001b[0m \u001b[43mcur\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mexecute\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;124;43mb\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mjoin\u001b[49m\u001b[43m(\u001b[49m\u001b[43mparts\u001b[49m\u001b[43m)\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m   1300\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m fetch:\n\u001b[0;32m   1301\u001b[0m     result\u001b[38;5;241m.\u001b[39mextend(cur\u001b[38;5;241m.\u001b[39mfetchall())\n",
      "File \u001b[1;32mc:\\Users\\oigla\\anaconda3\\lib\\encodings\\utf_8.py:15\u001b[0m, in \u001b[0;36mdecode\u001b[1;34m(input, errors)\u001b[0m\n\u001b[0;32m     11\u001b[0m \u001b[38;5;66;03m### Codec APIs\u001b[39;00m\n\u001b[0;32m     13\u001b[0m encode \u001b[38;5;241m=\u001b[39m codecs\u001b[38;5;241m.\u001b[39mutf_8_encode\n\u001b[1;32m---> 15\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mdecode\u001b[39m(\u001b[38;5;28minput\u001b[39m, errors\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mstrict\u001b[39m\u001b[38;5;124m'\u001b[39m):\n\u001b[0;32m     16\u001b[0m     \u001b[38;5;28;01mreturn\u001b[39;00m codecs\u001b[38;5;241m.\u001b[39mutf_8_decode(\u001b[38;5;28minput\u001b[39m, errors, \u001b[38;5;28;01mTrue\u001b[39;00m)\n\u001b[0;32m     18\u001b[0m \u001b[38;5;28;01mclass\u001b[39;00m \u001b[38;5;21;01mIncrementalEncoder\u001b[39;00m(codecs\u001b[38;5;241m.\u001b[39mIncrementalEncoder):\n",
      "\u001b[1;31mKeyboardInterrupt\u001b[0m: "
     ]
    }
   ],
   "source": [
    "# Открываем zip-архив\n",
    "with zipfile.ZipFile(f'{path}/sftp.zip', 'r') as zf:\n",
    "    # Получаем список файлов в архиве\n",
    "    file_names = zf.namelist()\n",
    "    # errors = pd.DataFrame()\n",
    "    counter = 1\n",
    "    for file_name in file_names:\n",
    "        # Читаем содержимое файлов\n",
    "        with zf.open(file_name) as file:\n",
    "            try:\n",
    "                file_data = pd.read_csv(file, sep=';', low_memory=False, )\n",
    "            except Exception as e:\n",
    "                print(f'Ошибка при чтении файла \"{file_name}\" : [{e}]')\n",
    "            print(f'Обрабатывается файл \"{counter}\" : {file_name}')\n",
    "                # переименование столбцов\n",
    "            file_data.rename(\n",
    "                columns={'Post_name': 'post_name', \n",
    "                            'Название субъекта РФ': 'region_name', \n",
    "                            'Тип записи':'record_type',\n",
    "                    }, inplace=True\n",
    "                )\n",
    "            # создаем новые поля, одно с именем файла, другое с общим количеством строк в файле\n",
    "            file_data['source_file_name'] = file_name\n",
    "            file_data['total_rows_in_file'] = file_data.shape[0]\n",
    "            # file_data = file_data.loc[:, ~file_data.columns.str.contains(' ')]\n",
    "            # file_data.drop_duplicates(subset='session_id')\n",
    "            file_data['slot_ts'] = pd.to_datetime(file_data['slot_ts'], format='%Y-%m-%dT%H:%M:%S.%f', errors='coerce')\n",
    "            file_data['create_ts'] = pd.to_datetime(file_data['create_ts'], format='%Y-%m-%dT%H:%M:%S.%f')\n",
    "            # запись в БД\n",
    "            file_data.to_sql('session_errors', engine, if_exists='append', index=False, schema='db01')\n",
    "            counter += 1\n",
    "#             errors = pd.concat([file_data, errors], ignore_index=True)\n",
    "# print(errors.columns, errors.shape) "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>session_id</th>\n",
       "      <th>region_name</th>\n",
       "      <th>step_id</th>\n",
       "      <th>step_name</th>\n",
       "      <th>error_code</th>\n",
       "      <th>final_state</th>\n",
       "      <th>mo_oid</th>\n",
       "      <th>mo_name</th>\n",
       "      <th>post_name</th>\n",
       "      <th>slot_ts</th>\n",
       "      <th>create_ts</th>\n",
       "      <th>record_type</th>\n",
       "      <th>referral_flg</th>\n",
       "      <th>source_file_name</th>\n",
       "      <th>total_rows_in_file</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>6e50cd04-4a42-4c77-8c7a-3b9ec002eaed</td>\n",
       "      <td>Воронежская область</td>\n",
       "      <td>3</td>\n",
       "      <td>ServiceOrSpecs</td>\n",
       "      <td>0</td>\n",
       "      <td>Ошибка отсутсвует</td>\n",
       "      <td>1.2.643.5.1.13.13.12.2.36.3408.0.241177</td>\n",
       "      <td>Поликлиника, БУЗ ВО \"Семилукская РБ им. А. В. ...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaT</td>\n",
       "      <td>2024-03-12 20:41:06.413000+03:00</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>12.03.2024.csv</td>\n",
       "      <td>590642</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>aa4e2eac-bef8-475c-aa54-9e154e9e3276</td>\n",
       "      <td>Воронежская область</td>\n",
       "      <td>3</td>\n",
       "      <td>ServiceOrSpecs</td>\n",
       "      <td>0</td>\n",
       "      <td>Ошибка отсутсвует</td>\n",
       "      <td>1.2.643.5.1.13.13.12.2.36.3408.0.241177</td>\n",
       "      <td>Поликлиника, БУЗ ВО \"Семилукская РБ им. А. В. ...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaT</td>\n",
       "      <td>2024-03-12 20:43:58.046000+03:00</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>12.03.2024.csv</td>\n",
       "      <td>590642</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2af7d3f5-8835-455b-8e9f-f7a3feee8802</td>\n",
       "      <td>Воронежская область</td>\n",
       "      <td>3</td>\n",
       "      <td>ServiceOrSpecs</td>\n",
       "      <td>0</td>\n",
       "      <td>Ошибка отсутсвует</td>\n",
       "      <td>1.2.643.5.1.13.13.12.2.36.3408.0.241177</td>\n",
       "      <td>Поликлиника, БУЗ ВО \"Семилукская РБ им. А. В. ...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaT</td>\n",
       "      <td>2024-03-12 17:45:57.290000+03:00</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>12.03.2024.csv</td>\n",
       "      <td>590642</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>9a7b689e-0ca8-4343-b7c0-d3d69c7f7bf8</td>\n",
       "      <td>Воронежская область</td>\n",
       "      <td>3</td>\n",
       "      <td>ServiceOrSpecs</td>\n",
       "      <td>0</td>\n",
       "      <td>Ошибка отсутсвует</td>\n",
       "      <td>1.2.643.5.1.13.13.12.2.36.3408.0.241177</td>\n",
       "      <td>Поликлиника, БУЗ ВО \"Семилукская РБ им. А. В. ...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaT</td>\n",
       "      <td>2024-03-12 20:52:48.723000+03:00</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>12.03.2024.csv</td>\n",
       "      <td>590642</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>31415993-4eb1-4a53-a17a-279e38513ed0</td>\n",
       "      <td>Воронежская область</td>\n",
       "      <td>3</td>\n",
       "      <td>ServiceOrSpecs</td>\n",
       "      <td>0</td>\n",
       "      <td>Ошибка отсутсвует</td>\n",
       "      <td>1.2.643.5.1.13.13.12.2.36.3408.0.241177</td>\n",
       "      <td>Поликлиника, БУЗ ВО \"Семилукская РБ им. А. В. ...</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaT</td>\n",
       "      <td>2024-03-12 12:47:53.987000+03:00</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>12.03.2024.csv</td>\n",
       "      <td>590642</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                             session_id          region_name  step_id  \\\n",
       "0  6e50cd04-4a42-4c77-8c7a-3b9ec002eaed  Воронежская область        3   \n",
       "1  aa4e2eac-bef8-475c-aa54-9e154e9e3276  Воронежская область        3   \n",
       "2  2af7d3f5-8835-455b-8e9f-f7a3feee8802  Воронежская область        3   \n",
       "3  9a7b689e-0ca8-4343-b7c0-d3d69c7f7bf8  Воронежская область        3   \n",
       "4  31415993-4eb1-4a53-a17a-279e38513ed0  Воронежская область        3   \n",
       "\n",
       "        step_name  error_code        final_state  \\\n",
       "0  ServiceOrSpecs           0  Ошибка отсутсвует   \n",
       "1  ServiceOrSpecs           0  Ошибка отсутсвует   \n",
       "2  ServiceOrSpecs           0  Ошибка отсутсвует   \n",
       "3  ServiceOrSpecs           0  Ошибка отсутсвует   \n",
       "4  ServiceOrSpecs           0  Ошибка отсутсвует   \n",
       "\n",
       "                                    mo_oid  \\\n",
       "0  1.2.643.5.1.13.13.12.2.36.3408.0.241177   \n",
       "1  1.2.643.5.1.13.13.12.2.36.3408.0.241177   \n",
       "2  1.2.643.5.1.13.13.12.2.36.3408.0.241177   \n",
       "3  1.2.643.5.1.13.13.12.2.36.3408.0.241177   \n",
       "4  1.2.643.5.1.13.13.12.2.36.3408.0.241177   \n",
       "\n",
       "                                             mo_name post_name slot_ts  \\\n",
       "0  Поликлиника, БУЗ ВО \"Семилукская РБ им. А. В. ...       NaN     NaT   \n",
       "1  Поликлиника, БУЗ ВО \"Семилукская РБ им. А. В. ...       NaN     NaT   \n",
       "2  Поликлиника, БУЗ ВО \"Семилукская РБ им. А. В. ...       NaN     NaT   \n",
       "3  Поликлиника, БУЗ ВО \"Семилукская РБ им. А. В. ...       NaN     NaT   \n",
       "4  Поликлиника, БУЗ ВО \"Семилукская РБ им. А. В. ...       NaN     NaT   \n",
       "\n",
       "                         create_ts  record_type  referral_flg  \\\n",
       "0 2024-03-12 20:41:06.413000+03:00            3             0   \n",
       "1 2024-03-12 20:43:58.046000+03:00            3             0   \n",
       "2 2024-03-12 17:45:57.290000+03:00            3             0   \n",
       "3 2024-03-12 20:52:48.723000+03:00            3             0   \n",
       "4 2024-03-12 12:47:53.987000+03:00            3             0   \n",
       "\n",
       "  source_file_name  total_rows_in_file  \n",
       "0   12.03.2024.csv              590642  \n",
       "1   12.03.2024.csv              590642  \n",
       "2   12.03.2024.csv              590642  \n",
       "3   12.03.2024.csv              590642  \n",
       "4   12.03.2024.csv              590642  "
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "errors.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "RangeIndex: 1267758 entries, 0 to 1267757\n",
      "Data columns (total 15 columns):\n",
      " #   Column              Non-Null Count    Dtype                    \n",
      "---  ------              --------------    -----                    \n",
      " 0   session_id          1267758 non-null  object                   \n",
      " 1   region_name         1267758 non-null  object                   \n",
      " 2   step_id             1267758 non-null  int64                    \n",
      " 3   step_name           1267758 non-null  object                   \n",
      " 4   error_code          1267758 non-null  int64                    \n",
      " 5   final_state         1267758 non-null  object                   \n",
      " 6   mo_oid              795234 non-null   object                   \n",
      " 7   mo_name             801726 non-null   object                   \n",
      " 8   post_name           552490 non-null   object                   \n",
      " 9   slot_ts             39068 non-null    datetime64[ns, UTC+03:00]\n",
      " 10  create_ts           1267758 non-null  datetime64[ns, UTC+03:00]\n",
      " 11  record_type         1267758 non-null  int64                    \n",
      " 12  referral_flg        1267758 non-null  int64                    \n",
      " 13  source_file_name    1267758 non-null  object                   \n",
      " 14  total_rows_in_file  1267758 non-null  int64                    \n",
      "dtypes: datetime64[ns, UTC+03:00](2), int64(5), object(8)\n",
      "memory usage: 145.1+ MB\n"
     ]
    }
   ],
   "source": [
    "errors.info()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "11548116"
      ]
     },
     "execution_count": 48,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "errors['session_id'].nunique()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "60"
      ]
     },
     "execution_count": 55,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "errors.duplicated(subset='session_id').sum()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>session_id</th>\n",
       "      <th>region_name</th>\n",
       "      <th>step_id</th>\n",
       "      <th>step_name</th>\n",
       "      <th>error_code</th>\n",
       "      <th>final_state</th>\n",
       "      <th>mo_oid</th>\n",
       "      <th>mo_name</th>\n",
       "      <th>post_name</th>\n",
       "      <th>slot_ts</th>\n",
       "      <th>create_ts</th>\n",
       "      <th>record_type</th>\n",
       "      <th>referral_flg</th>\n",
       "      <th>source_file_name</th>\n",
       "      <th>total_rows_in_file</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "Empty DataFrame\n",
       "Columns: [session_id, region_name, step_id, step_name, error_code, final_state, mo_oid, mo_name, post_name, slot_ts, create_ts, record_type, referral_flg, source_file_name, total_rows_in_file]\n",
       "Index: []"
      ]
     },
     "execution_count": 56,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "errors[errors['source_file_name'] == '24.02.2024.csv']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "RangeIndex: 11548176 entries, 0 to 11548175\n",
      "Data columns (total 15 columns):\n",
      " #   Column              Dtype                    \n",
      "---  ------              -----                    \n",
      " 0   session_id          object                   \n",
      " 1   region_name         object                   \n",
      " 2   step_id             int64                    \n",
      " 3   step_name           object                   \n",
      " 4   error_code          int64                    \n",
      " 5   final_state         object                   \n",
      " 6   mo_oid              object                   \n",
      " 7   mo_name             object                   \n",
      " 8   post_name           object                   \n",
      " 9   slot_ts             datetime64[ns, UTC+03:00]\n",
      " 10  create_ts           datetime64[ns, UTC+03:00]\n",
      " 11  record_type         int64                    \n",
      " 12  referral_flg        int64                    \n",
      " 13  source_file_name    object                   \n",
      " 14  total_rows_in_file  int64                    \n",
      "dtypes: datetime64[ns, UTC+03:00](2), int64(5), object(8)\n",
      "memory usage: 1.3+ GB\n"
     ]
    }
   ],
   "source": [
    "errors.info()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>session_id</th>\n",
       "      <th>region_name</th>\n",
       "      <th>step_id</th>\n",
       "      <th>step_name</th>\n",
       "      <th>error_code</th>\n",
       "      <th>final_state</th>\n",
       "      <th>mo_oid</th>\n",
       "      <th>mo_name</th>\n",
       "      <th>post_name</th>\n",
       "      <th>slot_ts</th>\n",
       "      <th>create_ts</th>\n",
       "      <th>record_type</th>\n",
       "      <th>referral_flg</th>\n",
       "      <th>source_file_name</th>\n",
       "      <th>total_rows_in_file</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>8545768</th>\n",
       "      <td>0fa29196-07d6-45b7-ba6b-031a5816205c</td>\n",
       "      <td>Амурская область</td>\n",
       "      <td>1</td>\n",
       "      <td>ValidatePerson</td>\n",
       "      <td>5</td>\n",
       "      <td>Внутренняя ошибка РМИС при создании записи</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaT</td>\n",
       "      <td>2024-02-07 08:49:34.843000+03:00</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>07.02.2024.csv</td>\n",
       "      <td>635293</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4508423</th>\n",
       "      <td>24dea935-5b38-4001-a38e-95cf615afd4b</td>\n",
       "      <td>Краснодарский край</td>\n",
       "      <td>1</td>\n",
       "      <td>ValidatePerson</td>\n",
       "      <td>1</td>\n",
       "      <td>Ошибка валидации данных пациента</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaT</td>\n",
       "      <td>2024-02-14 07:55:52.668000+03:00</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>14.02.2024.csv</td>\n",
       "      <td>559442</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4893656</th>\n",
       "      <td>e5fe0643-813b-49bf-9565-4356f6496c8c</td>\n",
       "      <td>Хабаровский край</td>\n",
       "      <td>4</td>\n",
       "      <td>Resource</td>\n",
       "      <td>0</td>\n",
       "      <td>Ошибка отсутсвует</td>\n",
       "      <td>1.2.643.5.1.13.13.12.2.27.2565.0.701515</td>\n",
       "      <td>Поликлиника №4, КГБУЗ \"ГОРОДСКАЯ БОЛЬНИЦА\" ИМЕ...</td>\n",
       "      <td>врач-травматолог-ортопед</td>\n",
       "      <td>NaT</td>\n",
       "      <td>2024-02-14 13:08:34.258000+03:00</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>14.02.2024.csv</td>\n",
       "      <td>559442</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5283028</th>\n",
       "      <td>15cba0ab-eeb7-4cd2-b53e-dd805b418e29</td>\n",
       "      <td>Республика Карелия</td>\n",
       "      <td>3</td>\n",
       "      <td>ServiceOrSpecs</td>\n",
       "      <td>8</td>\n",
       "      <td>Значение не найдено</td>\n",
       "      <td>1.2.643.5.1.13.13.12.2.10.666.0.29714</td>\n",
       "      <td>Отделение профилактики,ГБУЗ \"ГП № 1\"</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaT</td>\n",
       "      <td>2024-02-13 08:22:58.095000+03:00</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>13.02.2024.csv</td>\n",
       "      <td>623592</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4231095</th>\n",
       "      <td>5ce64ede-a4ec-4d68-a4b3-b1ead5ec438e</td>\n",
       "      <td>Ленинградская область</td>\n",
       "      <td>5</td>\n",
       "      <td>Slot</td>\n",
       "      <td>0</td>\n",
       "      <td>Ошибка отсутсвует</td>\n",
       "      <td>1.2.643.5.1.13.13.12.2.47.4451.0.64816</td>\n",
       "      <td>Детская поликлиника, ГБУЗ ЛО \"ТИХВИНСКАЯ МБ\"</td>\n",
       "      <td>фельдшер</td>\n",
       "      <td>NaT</td>\n",
       "      <td>2024-02-15 11:43:47.563000+03:00</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>15.02.2024.csv</td>\n",
       "      <td>536063</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                   session_id            region_name  step_id  \\\n",
       "8545768  0fa29196-07d6-45b7-ba6b-031a5816205c       Амурская область        1   \n",
       "4508423  24dea935-5b38-4001-a38e-95cf615afd4b     Краснодарский край        1   \n",
       "4893656  e5fe0643-813b-49bf-9565-4356f6496c8c       Хабаровский край        4   \n",
       "5283028  15cba0ab-eeb7-4cd2-b53e-dd805b418e29     Республика Карелия        3   \n",
       "4231095  5ce64ede-a4ec-4d68-a4b3-b1ead5ec438e  Ленинградская область        5   \n",
       "\n",
       "              step_name  error_code  \\\n",
       "8545768  ValidatePerson           5   \n",
       "4508423  ValidatePerson           1   \n",
       "4893656        Resource           0   \n",
       "5283028  ServiceOrSpecs           8   \n",
       "4231095            Slot           0   \n",
       "\n",
       "                                        final_state  \\\n",
       "8545768  Внутренняя ошибка РМИС при создании записи   \n",
       "4508423            Ошибка валидации данных пациента   \n",
       "4893656                           Ошибка отсутсвует   \n",
       "5283028                         Значение не найдено   \n",
       "4231095                           Ошибка отсутсвует   \n",
       "\n",
       "                                          mo_oid  \\\n",
       "8545768                                      NaN   \n",
       "4508423                                      NaN   \n",
       "4893656  1.2.643.5.1.13.13.12.2.27.2565.0.701515   \n",
       "5283028    1.2.643.5.1.13.13.12.2.10.666.0.29714   \n",
       "4231095   1.2.643.5.1.13.13.12.2.47.4451.0.64816   \n",
       "\n",
       "                                                   mo_name  \\\n",
       "8545768                                                NaN   \n",
       "4508423                                                NaN   \n",
       "4893656  Поликлиника №4, КГБУЗ \"ГОРОДСКАЯ БОЛЬНИЦА\" ИМЕ...   \n",
       "5283028               Отделение профилактики,ГБУЗ \"ГП № 1\"   \n",
       "4231095       Детская поликлиника, ГБУЗ ЛО \"ТИХВИНСКАЯ МБ\"   \n",
       "\n",
       "                        post_name slot_ts                        create_ts  \\\n",
       "8545768                       NaN     NaT 2024-02-07 08:49:34.843000+03:00   \n",
       "4508423                       NaN     NaT 2024-02-14 07:55:52.668000+03:00   \n",
       "4893656  врач-травматолог-ортопед     NaT 2024-02-14 13:08:34.258000+03:00   \n",
       "5283028                       NaN     NaT 2024-02-13 08:22:58.095000+03:00   \n",
       "4231095                  фельдшер     NaT 2024-02-15 11:43:47.563000+03:00   \n",
       "\n",
       "         record_type  referral_flg source_file_name  total_rows_in_file  \n",
       "8545768            3             0   07.02.2024.csv              635293  \n",
       "4508423            3             0   14.02.2024.csv              559442  \n",
       "4893656            3             0   14.02.2024.csv              559442  \n",
       "5283028            3             0   13.02.2024.csv              623592  \n",
       "4231095            3             0   15.02.2024.csv              536063  "
      ]
     },
     "execution_count": 51,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "errors.sample(5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "60"
      ]
     },
     "execution_count": 59,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "errors.duplicated(subset='session_id').sum()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
